<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!doctype html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="copyright" content=""/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>重置密码</title>
    <link href="<%=basePath%>hplus/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="<%=basePath%>hplus/css/font-awesome.min93e3.css?v=4.3.0" rel="stylesheet">
    <link href="<%=basePath%>hplus/css/animate.min.css" rel="stylesheet">
    <link href="<%=basePath%>hplus/css/style.min.css?v=3.0.0" rel="stylesheet">
    <link href="<%=basePath%>hplus/css/style.min.css?v=3.0.0" rel="stylesheet">
    <link href="../favicon.ico" rel="shortcut icon">
    
    <style type="text/css">
		.s_btn{
            float: right;
            margin: 23px 10% 0 0;
            width: 120px;
        }
        .buzhou{width: 100%;text-align: center;font-size: 16px;margin: 30px 0;}
        .buzhou td{border-bottom: 4px solid #ddd;padding: 10px 0;}
        .buzhou td>span{display: inline-block;background: #bbb;width: 24px;height: 24px;border-radius: 12px;margin-right: 8px;color: white;}
        .buzhou td.current{color: #18a689;border-bottom-color: #18a689;}
        .buzhou td.current>span{background: #18a689;}
	</style>
</head>
<body class="gray-bg">
	<div class="ibox-content" style="height:80px;line-height:80px;padding:0;"> 
        <img src="<%=basePath%>hplus/img/logo.jpg" style="margin-left:10%"/>
        <button type="button" class="btn btn-outline btn-primary s_btn" id="gotologin">登录</button>
    </div>
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-4 col-sm-offset-4">
			<table class="buzhou">
				<tr>
					<td class="current"><span>1</span>身份验证</td>
					<td class="current"><span>2</span>重置密码</td>
				</tr>
			</table>
		</div>
	</div>
    <div class="col-sm-4" style="float: none;margin: 0 auto">
        <div class="ibox-title">
        	<form novalidate="novalidate" class="form-horizontal" id="forgetForm">
                <div class="form-group">
                    <label class="col-sm-4 control-label">请设置新密码：</label>

                    <div class="col-sm-7">
                        <input id="new_pwd_one" placeholder="请设置新密码" name="mobile" class="form-control"
                               type="password">

                        <em id="a" class="s_red_three text-danger"></em>
                        <span class="help-block m-b-none "></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">再次输入新密码：</label>

                    <div class="col-sm-7">
                        <input id="new_pwd_two" placeholder="请再次输入新密码" name="mobile" class="form-control"
                               type="password">
                        <em id="error_msg" class="s_red_three text-danger"></em>
                        <span class="help-block m-b-none "></span>
                    </div>
                </div>


                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-3" style="float: none;margin: 0 auto;text-align: center">
                        <button class="btn btn-primary s_dl_button" type="button" id="next">提 交</button>
                    </div>
                </div>
            </form>
        </div>
<!--         <div class="ibox-content"> -->
<!--             <form novalidate="novalidate" class="form-horizontal" id="forgetForm"> -->
<!--                 <div class="form-group"> -->
<!--                     <label class="col-sm-4 control-label">请设置新密码：</label> -->

<!--                     <div class="col-sm-7"> -->
<!--                         <input id="new_pwd_one" placeholder="请设置新密码" name="mobile" class="form-control" -->
<!--                                type="password"> -->

<!--                         <em id="a" class="s_red_three text-danger"></em> -->
<!--                         <span class="help-block m-b-none "></span> -->
<!--                     </div> -->
<!--                 </div> -->
<!--                 <div class="form-group"> -->
<!--                     <label class="col-sm-4 control-label">请再次输入新密码：</label> -->

<!--                     <div class="col-sm-7"> -->
<!--                         <input id="new_pwd_two" placeholder="请再次输入新密码" name="mobile" class="form-control" -->
<!--                                type="password"> -->
<!--                         <em id="error_msg" class="s_red_three text-danger"></em> -->
<!--                         <span class="help-block m-b-none "></span> -->
<!--                     </div> -->
<!--                 </div> -->


<!--                 <div class="form-group"> -->
<!--                     <div class="col-sm-8 col-sm-offset-3" style="float: none;margin: 0 auto;text-align: center"> -->
<!--                         <button class="btn btn-primary s_dl_button" type="button" id="next">提 交</button> -->
<!--                     </div> -->
<!--                 </div> -->
<!--             </form> -->
<!--         </div> -->
    </div>
</div>

<script src="<%=basePath%>hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>hplus/js/plugins/sweetalert/sweetalert2.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
    $('.s_psw_list li .s_input_box input').focus(function () {
        $(this).addClass('focus');
    });
    $('.s_psw_list li .s_input_box input').blur(function () {
        $(this).removeClass('focus');
    });
    
    $('#gotologin').click(function(){
    	window.location.href = "<%=basePath%>";
    });
</script>
<script type="text/javascript">
    $(function () {
        var url = "<%=basePath%>/account/ajaxRetrievePwd";
        $('.s_dl_button').click(function () {
            var old_pwd = $('#old_pwd').val();
            var result = checkPwd();
            if (!result) {
                return;
            }
            $.post(
                url,
                {
                    "pwd": new_pwd_one
                },
                function (data) {
                    if ("200" == data.status) {
                        <%--window.location.href = "<%=basePath%>/ui/resetPwdSucc";--%>

                        swal({
                            title: "重置密码成功!",	
                            icon: "success",
                            button: "重新登陆",
                            type: 'success',
                        }).then(function () {
                            window.location.href = "<%=basePath%>";
                        });

                    } else {
                        showDialog("重置失败");
                        setTimeout('window.location.href = "<%=basePath%>/view/ui/recoverPwd"', 1300);
                        //window.location.href = "<%=basePath%>/view/ui/recoverPw";
                    }
                }, "json");
        });
    });
</script>
<script type="text/javascript">
    var new_pwd_one;
    var new_pwd_two;
    function checkPwd() {
        new_pwd_one = $('#new_pwd_one').val();
        new_pwd_two = $('#new_pwd_two').val();
        if (new_pwd_one != new_pwd_two) {
            $('#error_msg').text("两次密码输入不一致");
            $('#li_ag').attr('class', 's_red_border');
            $('#new_pwd_two').val("");
            return false;
        } else {
            $('#li_ft').attr('class', '');
            $('#li_ag').attr('class', '');
            $('#error_msg').text("");
        }
        //用户输入的密码
        var password = $('#new_pwd_one').val();
        if (password.length < 6 || password.length > 20) {
            $('#error_msg').text("请输入6到20位密码");
            $('#li_ft').attr('class', 's_red_border');
            $('#li_ag').attr('class', 's_red_border');
            return false;
        }
        //正则表达式,必须要有数字和字母，为6到10位
        var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;			
        //判断
        if (!reg.test(password)) {
            $('#error_msg').text("密码不符合规范,必须要有数字和字母");
            $('#li_ft').attr('class', 's_red_border');
            document.getElementById("new_pwd_one").Value = "";
            return false;
        } else {
            return true;
        }
    }
</script>
<script type="text/javascript">
    $('#new_pwd_one').focus(function () {
        $('#li_ft').attr('class', '');
        $('#li_ag').attr('class', '');
        $('#error_msg').text("");
    });
    $('#new_pwd_two').focus(function () {
        $('#li_ft').attr('class', '');
        $('#li_ag').attr('class', '');
        $('#error_msg').text("");
    });
    $('.J_xpassw').click(function () {
        var $this = $(this),
            input = $this.parents('.right').find('.text');
        if ($this.hasClass('on')) {
            $this.removeClass('on');
            $('#new_pwd_one').attr('type', 'text');
            $('#new_pwd_two').attr('type', 'text');
        } else {
            $this.addClass('on');
            $('#new_pwd_one').attr('type', 'password');
            $('#new_pwd_two').attr('type', 'password');
        }
        ;
    });
    function showDialog(title) {
        $('#dialog_title').html('<img src="${pageContext.request.contextPath}/images/system/s_tick.png"/>' + title + '');
        $('.s_popup_delect2,.s_consum').show().delay(2000).fadeOut();
    }
</script>
</body>
</html>

